home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13921 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: prairienet.org!sjmccaug
  2. From: sjmccaug@prairienet.org (Scott J. McCaughrin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Passing numbers
  5. Date: 28 Mar 1996 00:04:09 GMT
  6. Organization: University of Illinois at Urbana
  7. Message-ID: <4jcl1p$5mn@vixen.cso.uiuc.edu>
  8. References: <4jchjq$i1k@news1.h1.usa.pipeline.com> <40.88694.1613@channel1.com>
  9. Reply-To: sjmccaug@prairienet.org (Scott J. McCaughrin)
  10. NNTP-Posting-Host: firefly.prairienet.org
  11.  
  12.  
  13. In a previous article, grantp@usa.pipeline.com (Pete Grant) says:
  14.  
  15. >On Mar 27, 1996 06:28:00 in article <Passing numbers>,
  16. >'dspse.bedford@channel1.com (Dspse Bedford)' wrote: 
  17. >>Lets say I have the following class and functions defined: 
  18. >> 
  19. >>class A{ 
  20. >>... 
  21. >>void func(long lvar); 
  22. >>void func(int  ivar); 
  23. >>.... 
  24. >>}; 
  25. >>I know that the compiler can not decide if  
  26. >>A a; 
  27. >>a.func(30); 
  28. >> 
  29. >>should match up with the int version of func or the long version of  
  30. >>func.  However, is there anyway I can tell the compiler which one to  
  31. >>use as a default definition such that the above would always be mapped 
  32. >>to my default definition.  In other words, if an arguement, such as 
  33. >>a number, causes an ambiguity use the default definition.  Does anyone 
  34. >>know how or why not? 
  35. >> 
  36. >Which compiler doesn't distinguish between int and long? 
  37. >MSVC++4.1 does. 
  38. >a.func(30) => func(int); 
  39. >a.func(5L) => func(long); 
  40. >-- 
  41.  
  42.  That wasn't the author's point: 30 is an int that also falls
  43.  in the range of a long. The answer is that, owing to its
  44.  size, 30 "defaults" to an int, just as 66000 defaults to a
  45.  long. So yes, there is a way to to choose between the two.
  46.  
  47.  Scott
  48.  
  49. >Kalevi, Inc. 
  50. >Software Engineering & development
  51. >
  52.  
  53.